<!DOCTYPE html>
<html lang="zh-cn" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="_fragments :: head(~{::title})">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet">
    <title>INSTAR-人工智能实验箱</title>
    <link rel="shortcut icon" href="../static/favicon.ico" type="image/x-icon">
</head>

<link rel="stylesheet" href="../static/css/video.css" th:href="@{/css/video.css}">
<link rel="stylesheet" href="../static/css/header.css" th:href="@{/css/header.css}">
<body>


<!--------------------头部-begin------------------------------>
<header id="lk_header" th:replace="_fragments :: header(2)">

    <nav class="navbar navbar-expand-lg navbar-light navbar-lk bg-light">
        <div class="container">
            <a class="navbar-brand d-flex justify-content-center align-items-center" href="#">
                <h2 class="mt-2 text-primary"><strong>INSTAR</strong></h2>
            </a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#lk_nav"
                    aria-controls="lk_nav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse" id="lk_nav">
                <ul class="navbar-nav mr-auto">
                    <li class="nav-item active">
                        <a class="nav-link" href="#">产品中心<span class="sr-only">(current)</span></a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="https://study.163.com/courses-search?keyword=%E6%92%A9%E8%AF%BE#/?ot=5" target="_blank">视频教程</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="https://study.163.com/courses-search?keyword=%E6%92%A9%E8%AF%BE#/?ot=5" target="_blank">资料下载</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="http://www.itlike.com/software/index.html">开源社区</a>
                    </li>

                </ul>
                <form class="form-inline pl-3 pr-3">
                    <div class="input-group">
                        <div class="input-group-prepend">
                            <span class="input-group-text" id="basic-addon1">帖子</span>
                        </div>
                        <input type="text" class="form-control" placeholder="请输入你要搜索的帖子" aria-label="search" aria-describedby="basic-addon1">
                    </div>
                    <button class="btn btn-outline-primary my-2 my-sm-0" type="submit">Search</button>
                </form>
            </div>
        </div>
    </nav>
</header>
<!--------------------头部-end------------------------------>

<!-- 视频部分 -->
<section id="lk_video" class="container mt-5 mb-5">
    <div class="row">
        <!--左半部分-->
        <div class="col-sm-12 col-md-4 col-lg-3 shadow-lg mb-5 bg-white pr-0 pl-0 rounded-left" style="border-right: 3px solid darkgrey">
            <!--待修改的搜索框-->
                  <form class="form-inline mt-3 media pr-2 pl-2" action="/video/search" method="post" th:action="@{/video/search}">
                      <div class="input-group media-body">
                              <input type="text" class="form-control" name="condition" placeholder="你要搜索的视频" >
                      </div>
                      <button class="btn btn-outline-primary" id="search" type="button">搜索</button>
                  </form>
        <div class="p-2 mt-3 pl-3" style="background-color: #aadcff">
            <span style="color: white"><strong>视频教程</strong></span>
            <span style="color: white" class="float-right"><strong> > </strong></span>
        </div>

        <div id="course"  >
            <ul>
                <li class="active pl-3"  onclick="getvideos(this)" id="0"><a>全部视频</a> <small th:text="${total}">32</small></li>
<!--                <li class="pl-3" onclick="getvideos(this)" id="1"  th:each="vcategory:${vcategories}" th:id="${vcategory.key.id}"><a th:text="${vcategory.key.name}">机器学习理论</a><small th:text="${vcategory.value}">32</small></li>-->
                <li class="pl-3" onclick="getvideos(this)" id="1"  th:each="vcategory:${vcategories}" th:id="${vcategory.id}"><a th:text="${vcategory.name}">机器学习理论</a><small th:text="${#arrays.length(vcategory.videos)}">32</small></li>
            </ul>

        </div>

        </div>
        <!--右半部分-->
        <div  class="col-sm-12 col-md-8 col-lg-9 bg-light shadow-sm p-3 mb-5 bg-white"  >
            <div class="container-fluid videolist" th:fragment="videolist">

                <div class="row" >
<!--                    <div th:text="${#lists.isEmpty(videos)}">-->
<!--                        <img src="../static/images/notFound.jpg" alt="">-->
<!--                        <h3 style="color: #7abaff">这里空空如也，但我们会尽快添加相关视频的！</h3>-->
<!--                    </div>-->
                    <div class="col-6 col-sm-6 col-lg-4 mb-3 mt-3" th:each="video : ${videos}">

                        <a href="#" th:href="@{${video.video_url}}" target="_blank">
                        <div class="video_click box mb-2">
                            <img referrerpolicy="no-referrer" class="img-thumbnail image-responsive" src="../static/images/Blog_img3.jpg" th:src="${video.pic_url}" />
<!--                            <span class="video_time">2021-1-14</span>-->
                            <div class="box-content">
                                <span class="title" th:text="${video.info}">三天玩转机器学习</span>
                            </div>
                        </div>
                        <span th:text="${video.title}">计算机云智能时代，我们要...</span>
                        </a>
                    </div>

                </div>
                <!--翻页按钮-->

                <nav class="blog-pagination" aria-label="Pagination"  th:if="${videos.totalPages}>1">
                    <a class="btn btn-outline-primary " id="previous" onclick="changePage(this)" th:name="${videos.number}-1" th:unless="${videos.first}"><span aria-hidden="true">&larr;</span>上一页</a>
                    <a class="btn btn-outline-primary float-right" id="next" onclick="changePage(this)" th:name="${videos.number}+1" th:unless="${videos.last}">下一页<span aria-hidden="true">&rarr;</span></a>
                </nav>
            </div>

        </div>
    </div>
</section>

<br><br><br><br><br><br><br><br>
<footer th:replace="_fragments :: footer"></footer>

<!--/*/<th:block th:replace="_fragments :: script">/*/-->
<script src="../static/js/jquery-3.3.1.js"></script>
<script src="../static/js/popper.js"></script>
<script src="../static/js/bootstrap.js"></script>
<!--/*/</th:block>/*/-->
<script>
    var lastactive=0;
    function getvideos(obj) {
        var id=obj.id;
        $.ajax({
            url: 'http://'+HOST+'/videolist',
            type: 'POST',
            data:{value:id},
            success: function (data) {
                $(".videolist").html(data);
            }
        });
        $("#"+lastactive).removeClass("active");
        $("#"+id).addClass("active");
        lastactive=id;
    }
    $('#search').click(function () {
        $(".videolist").load(/*[[@{/video/search}]]*/"/video/search", {
            condition: $("[name='condition']").val(),
            id:lastactive
        })
    });

    function changePage(obj){
        var name = obj.name;
            $(".videolist").load(/*[[@{/videos}]]*/"/videos", {
                page: name
            })
    }
</script>
</body>
</html>